package com.zky.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.zky.DAO.impl.Users1DaoImp;
import com.zky.entity.Users1;

public class Regist1Action extends Users1DaoImp {
	//public Users1 users1;
	public String username;
	public String password;
	public String email;
	


	public String verifyCode;
	
	
	

	HttpServletRequest request = ServletActionContext.getRequest(); 
	HttpServletRequest session = ServletActionContext.getRequest();
	HttpSession s = request.getSession();
	
/*	public Users1 getUsers1() {
		return users1;
	}

	public void setUsers1(Users1 users1) {
		this.users1 = users1;
	}*/

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}



	public String getVerifyCode() {
		return verifyCode;
	}

	public void setVerifyCode(String verifyCode) {
		this.verifyCode = verifyCode;
	}
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	
	public String Regist(){
		String num=(String)s.getAttribute("rand");
		Users1 users1=new Users1();
		if(verifyCode.equals(num)&&(this.findAll3(username)==null||this.findAll3(username).size()==0)){
			users1.setUsername(username);
			users1.setPsw(password);
			users1.setEmail(email);
			this.save(users1);
			System.out.print("success");
			return "success";
		}else{
			System.out.print("false");
			return "false";
		}
		
		
		
	}
	

}
